﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="admin_NewsAdmin_Default" %>
<%@ MasterType VirtualPath="~/admin/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <!-- iCheck -->
    <link rel="stylesheet" href="<%=ResolveUrl("~/plugins/iCheck/flat/blue.css")%>">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>网站新闻管理
            </h1>
            <ol class="breadcrumb">
                <li><a href="Default.aspx"><i class="fa fa-bullhorn"></i>网站新闻管理</a></li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- /.col -->
                <div class="col-md-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">网站新闻管理</h3>

                            <div class="box-tools pull-right" style="margin-right:48px">
                                <div class="has-feedback" style="width:177px">
                                    <asp:TextBox ID="TextBox1" runat="server" CssClass="form-control input-sm" placeholder="搜索新闻 ..."></asp:TextBox>
                                    <span class="glyphicon glyphicon-search form-control-feedback"></span>
                                </div>
                            </div>
                            <div class="box-tools pull-right">
                                <asp:Button ID="Button1" runat="server" Text="搜索" CssClass="btn btn-default btn-sm" Height="30" OnClick="Search" />
                            </div>
                            <!-- /.box-tools -->
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body no-padding">
                            <div class="table-responsive mailbox-messages">
                                <asp:GridView ID="GridView1" runat="server" PageSize="20" AutoGenerateColumns="False" AllowPaging="True" CssClass="table table-striped" GridLines="None" OnPageIndexChanging="GridView1_PageIndexChanging" EmptyDataText="暂无数据">
                                    <Columns>
                                        <asp:TemplateField HeaderText="标题" HeaderStyle-CssClass="mailbox-name">
                                            <ItemTemplate>
                                                <asp:HyperLink ID="HyperLink0" NavigateUrl=<%# "~/admin/NewsAdmin/Read.aspx?read="+Eval("id") %> runat="server"><%# Eval("title") %></asp:HyperLink>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="来源" HeaderStyle-CssClass="mailbox-subject">
                                            <ItemTemplate>
                                                <%# Eval("source") %>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="新闻栏目" HeaderStyle-CssClass="mailbox-subject">
                                            <ItemTemplate>
                                                <b><%# Eval("column_name") %></b>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="作者" HeaderStyle-CssClass="mailbox-subject">
                                            <ItemTemplate>
                                                <asp:HyperLink ID="HyperLink2" NavigateUrl=<%# "~/admin/User/Show.aspx?id="+Eval("user_id") %> runat="server" CssClass="cursor"><b><%# Eval("writer") %></b></asp:HyperLink>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="发布日期" HeaderStyle-CssClass="mailbox-date">
                                            <ItemTemplate>
                                                <%# Eval("created_at") %>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="操作" HeaderStyle-CssClass="mailbox-date">
                                            <ItemTemplate>
                                                <asp:HyperLink ID="HyperLink2" onclick=<%# "openDialog(" + Eval("id") + ")" %> runat="server" CssClass="cursor">删除</asp:HyperLink>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <PagerTemplate>
                                        <div class="mailbox-controls">
                                            <div class="pull-right">
                                                <asp:Label ID="lblPage" runat="server" Text='<%# "第" + (((GridView)Container.NamingContainer).PageIndex + 1)  + "页/共" + (((GridView)Container.NamingContainer).PageCount) + "页" %> '></asp:Label>
                                                <div class="btn-group">
                                                    <asp:LinkButton ID="lbnFirst" runat="Server" CssClass="btn btn-default" Text="首页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="First"></asp:LinkButton>
                                                    <asp:LinkButton ID="lbnPrev" runat="server" CssClass="btn btn-default" Text="上一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>' CommandName="Page" CommandArgument="Prev"></asp:LinkButton>
                                                    <asp:LinkButton ID="lbnNext" runat="Server" CssClass="btn btn-default" Text="下一页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Next"></asp:LinkButton>
                                                    <asp:LinkButton ID="lbnLast" runat="Server" CssClass="btn btn-default" Text="尾页" Enabled='<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>' CommandName="Page" CommandArgument="Last"></asp:LinkButton>
                                                </div>
                                            </div>
                                        </div>
                                    </PagerTemplate>
                                </asp:GridView>
                            </div>
                            <!-- /.mail-box-messages -->
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /. box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
            <div id="delModal" class="modal fade" role="dialog" aria-labelledby="delTitle" aria-hidden="true">
                <div class="modal-dialog modal-sm">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                            <h4 class="modal-title" id="delTitle">确认删除吗？</h4>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary" onclick="confirm()">确认</button>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="script" runat="Server">
    <!-- iCheck -->
    <script src="<%=ResolveUrl("~/plugins/iCheck/icheck.min.js")%>"></script>
    <script>
        var del_id;
        function openDialog(id) {
            del_id = id;
            $('#delModal').modal('show');
        }
        function confirm() {
            if (del_id != null) {
                location.href = "/admin/NewsAdmin/Default.aspx?del_id=" + del_id + "";
            }
        }
    </script>
</asp:Content>

